package com.jason.data;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class StreamDemo {

    public static void main(String[] args) {

        List<String> list1 = new ArrayList<>();
        list1.add("asda");
        list1.add("dweqweq");
        list1.add("sdaf234324");
        //list1.stream().forEach((n)-> System.out.println(n));

        List<String> list2 = new ArrayList<>();
        //Integer
        list1.stream().forEach(list2::add);
       // list2.stream().forEach(n-> System.out.println(n));

        Student s1 = new Student();
        s1.setAge(20);
        s1.setName("你好");

        Student s2 = new Student();
        s2.setAge(21);
        s2.setName("和飒飒");

        List<Student> list3 = new ArrayList<>();
        list3.add(s1);
        list3.add(s2);

        List<Student> list4 = new ArrayList<>();
        list3.stream().forEach(list4::add);
        //list4.stream().forEach((n) -> System.out.println((n.getName()+"--->"+n.getAge())));


        List<ClassDemo> list5  = new ArrayList<>();


        /*list3.stream().reduce((a,b)->{

        });*/
        //list3.stream().map()
       //list5 =  list3.stream().map(Student::getName).collect(Collectors.toList());
    }

    /**
     * 获取属性名数组
     * */
    private String[] getFiledName(Object o) {
        Field[] fields=o.getClass().getDeclaredFields();
        String[] fieldNames=new String[fields.length];
        for(int i=0;i<fields.length;i++){
            System.out.println(fields[i].getType());
            fieldNames[i]=fields[i].getName();
        }
        return fieldNames;
    }
}
